/**
 * @file       Mutex.h
 * @brief      CMutex
 * @author     Huabo Zheng
 * @date       Jan 31, 2012
 * @Copyright  2012, www.netgear.com Inc. All rights reserved.
 */
#ifndef MUTEX_H_
#define MUTEX_H_

#include "Object.h"
#include "typedefine.h"
#include <pthread.h>

namespace NS_LCD_AFW
{

/**
 *@class  CMutex
 *@brief  CMutex
 */
class CMutex: public NS_LCD_AFW::CObject
{
public:

	/**
	 *@brief Constructor
	 */
	CMutex();

	/**
	*@brief DeConstructor
	*/
	virtual ~CMutex();
public:

	/**
	 *@brief  Waits on a synchronization object.
	 *@details   Call this function to gain access to the resource controlled by the synchronization object
	 *@exception none
	 *@retval    int
	 *@return    0 if the function was successful; otherwise failure .
	 *@note
	 *@attention
	 *@see unLock
	*/
	virtual int lock();

	/**
	 *@brief Releases a synchronization object.
	 *@details    Releases the synchronization object owned by CMutex
	 *@exception none
	 *@retval    int
	 *@return    0 if the function was successful; otherwise failure .
	 *@note
	 *@attention
	 *@see lock
	*/
	virtual int unLock();

private:
	pthread_mutex_t m_mutex;

private:
DISABLE_COPY_CONSTRUCTOR_AND_ASSIGN_REFERENCE(CMutex);
};

} /* namespace NS_LCD_AFW */
#endif /* MUTEX_H_ */
